package cn.innosmart.aq.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

import cn.innosmart.aq.R;
import cn.innosmart.aq.util.SystemConstant;

/**
 * Created by David on 2015/10/10.
 */
public class BoxDetailMoreAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater mLayoutInflater;
    private List<String> columns;
    private Integer[] imgs = {
            R.drawable.bottom_manager_normal, R.drawable.upgrade, R.drawable.wifi_icon, R.drawable.work_log, R.drawable.bottom_manager_normal, R.drawable.bottom_manager_normal,R.drawable.bottom_manager_normal
    };

    public BoxDetailMoreAdapter(Context context) {
        this.context = context;
        mLayoutInflater = LayoutInflater.from(context);
        columns = new ArrayList<>();
        columns.add(context.getString(R.string.activity_more_device_manager));
        columns.add(context.getString(R.string.activity_more_reboot));
        columns.add(context.getString(R.string.set_wifi_title));
        columns.add(context.getString(R.string.enable_maintain_mode));
        columns.add(context.getString(R.string.assign_provider));
        columns.add(context.getString(R.string.assign_setting));
//        columns.add("Fullscreen");
//        columns.add(context.getString(R.string.enable_poweroff_offline_alarm));
//        columns.add(context.getString(R.string.enable_power_online_restore_alarm));

//        columns.add(context.getString(R.string.disable_maintain_mode));
//        columns.add(context.getString(R.string.disable_maintain_mode));
//        columns.add(context.getString(R.string.activity_more_work_log_manager));
//        columns.add(context.getString(R.string.activity_more_reminder));
    }

    public void updateMaintainMode(int maintainMode) {
        if (maintainMode == 0) {
            columns.set(3, context.getString(R.string.enable_maintain_mode));
        } else {
            columns.set(3, context.getString(R.string.disable_maintain_mode));
        }
    }

    @Override
    public int getCount() {
        return columns.size();
    }

    @Override
    public Object getItem(int position) {
        return columns.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.gridview_more_item, null);
            holder.ivPic = (ImageView) convertView.findViewById(R.id.image_item);
            holder.tvTitle = (TextView) convertView.findViewById(R.id.text_item);
            convertView.setTag(holder);
            AutoUtils.auto(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tvTitle.setText(columns.get(position));
        holder.ivPic.setBackgroundResource(imgs[position]);
        return convertView;
    }

    static class ViewHolder {
        ImageView ivPic;
        TextView tvTitle;
    }
}
